package com.hbsoft.library.com.notepad;

import java.io.File;
//import javax.swing.filechooser.*;
import javax.swing.filechooser.FileFilter;

class NoteFileFilter extends FileFilter
{
	String ext;
	public NoteFileFilter(String ext)
	{
		this.ext=ext;
		
	}
	
	public boolean accept(File file)
	{
		if(file.isDirectory())
			return true;
		String filename=file.getName();
		int index=filename.lastIndexOf('.');
		if(index>=0&&index<filename.length()-1)
		{
			String extension=filename.substring(index+1).toLowerCase();
			if(extension.equals(ext));
			return true;
		}
		return false;
	} 
	
	public String getDescription()
	{
		if(ext.equals("txt"))
		return "(.txt)";
		return "";
	}
}